﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.Remoting.Messaging;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Automation;

namespace WinRpaLib
{
    public static class ControlTypeHelper
    {
        static Dictionary<String, UInt32> _ontrolTypeDic = new Dictionary<String, UInt32>();

        static ControlTypeHelper()
        {
                _ontrolTypeDic.Add("appbar", 50040);  //AppBarUIA_AppBarControlTypeIdIdentifies the AppBar control type
                _ontrolTypeDic.Add("button", 50000);  //ButtonUIA_ButtonControlTypeIdIdentifies the Button control type.
                _ontrolTypeDic.Add("calendar", 50001);  //CalendarUIA_CalendarControlTypeIdIdentifies the Calendar control type.
                _ontrolTypeDic.Add("checkbox", 50002);  //CheckBoxUIA_CheckBoxControlTypeIdIdentifies the CheckBox control type.
                _ontrolTypeDic.Add("combobox", 50003);  //ComboBoxUIA_ComboBoxControlTypeIdIdentifies the ComboBox control type.
                _ontrolTypeDic.Add("custom", 50025);  //CustomUIA_CustomControlTypeIdIdentifies the Custom control type.
                _ontrolTypeDic.Add("datagrid", 50028);  //DataGridUIA_DataGridControlTypeIdIdentifies the DataGrid control type.
                _ontrolTypeDic.Add("dataitem", 50029);  //DataItemUIA_DataItemControlTypeIdIdentifies the DataItem control type.
                _ontrolTypeDic.Add("document", 50030);  //DocumentUIA_DocumentControlTypeIdIdentifies the Document control type.
                _ontrolTypeDic.Add("edit", 50004);  //EditUIA_EditControlTypeIdIdentifies the Edit control type.
                _ontrolTypeDic.Add("group", 50026);  //GroupUIA_GroupControlTypeIdIdentifies the Group control type.
                _ontrolTypeDic.Add("header", 50034);  //HeaderUIA_HeaderControlTypeIdIdentifies the Header control type.
                _ontrolTypeDic.Add("headeritem", 50035);  //HeaderItemUIA_HeaderItemControlTypeIdIdentifies the HeaderItem control type.
                _ontrolTypeDic.Add("hyperlink", 50005);  //HyperlinkUIA_HyperlinkControlTypeIdIdentifies the Hyperlink control type.
                _ontrolTypeDic.Add("image", 50006);  //ImageUIA_ImageControlTypeIdIdentifies the Image control type.
                _ontrolTypeDic.Add("list", 50008);  //ListUIA_ListControlTypeIdIdentifies the List control type.
                _ontrolTypeDic.Add("listitem", 50007);  //ListItemUIA_ListItemControlTypeIdIdentifies the ListItem control type.
                _ontrolTypeDic.Add("menubar", 50010);  //MenuBarUIA_MenuBarControlTypeIdIdentifies the MenuBar control type.
                _ontrolTypeDic.Add("menu", 50009);  //MenuUIA_MenuControlTypeIdIdentifies the Menu control type.
                _ontrolTypeDic.Add("menuitem", 50011);  //MenuItemUIA_MenuItemControlTypeIdIdentifies the MenuItem control type.
                _ontrolTypeDic.Add("pane", 50033);  //PaneUIA_PaneControlTypeIdIdentifies the Pane control type.
                _ontrolTypeDic.Add("progressbar", 50012);  //ProgressBarUIA_ProgressBarControlTypeIdIdentifies the ProgressBar control type.
                _ontrolTypeDic.Add("radiobutton", 50013);  //RadioButtonUIA_RadioButtonControlTypeIdIdentifies the RadioButton control type.
                _ontrolTypeDic.Add("scrollbar", 50014);  //ScrollBarUIA_ScrollBarControlTypeIdIdentifies the ScrollBar control type.
                _ontrolTypeDic.Add("semanticzoom", 50039);  //SemanticZoomUIA_SemanticZoomControlTypeIdIdentifies the SemanticZoom control type
                _ontrolTypeDic.Add("separator", 50038);  //SeparatorUIA_SeparatorControlTypeIdIdentifies the Separator control type.
                _ontrolTypeDic.Add("slider", 50015);  //SliderUIA_SliderControlTypeIdIdentifies the Slider control type.
                _ontrolTypeDic.Add("spinner", 50016);  //SpinnerUIA_SpinnerControlTypeIdIdentifies the Spinner control type.
                _ontrolTypeDic.Add("splitbutton", 50031);  //SplitButtonUIA_SplitButtonControlTypeIdIdentifies the SplitButton control type.
                _ontrolTypeDic.Add("statusbar", 50017);  //StatusBarUIA_StatusBarControlTypeIdIdentifies the StatusBar control type.
                _ontrolTypeDic.Add("tab", 50018);  //TabUIA_TabControlTypeIdIdentifies the Tab control type.
                _ontrolTypeDic.Add("tabitem", 50019);  //TabItemUIA_TabItemControlTypeIdIdentifies the TabItem control type.
                _ontrolTypeDic.Add("table", 50036);  //TableUIA_TableControlTypeIdIdentifies the Table control type.
                _ontrolTypeDic.Add("text", 50020);  //TextUIA_TextControlTypeIdIdentifies the Text control type.
                _ontrolTypeDic.Add("thumb", 50027);  //ThumbUIA_ThumbControlTypeIdIdentifies the Thumb control type.
                _ontrolTypeDic.Add("titlebar", 50037);  //TitleBarUIA_TitleBarControlTypeIdIdentifies the TitleBar control type.
                _ontrolTypeDic.Add("toolbar", 50021);  //ToolBarUIA_ToolBarControlTypeIdIdentifies the ToolBar control type.
                _ontrolTypeDic.Add("tooltip", 50022);  //ToolTipUIA_ToolTipControlTypeIdIdentifies the ToolTip control type.
                _ontrolTypeDic.Add("tree", 50023);  //TreeUIA_TreeControlTypeIdIdentifies the Tree control type.
                _ontrolTypeDic.Add("treeitem", 50024);  //TreeItemUIA_TreeItemControlTypeIdIdentifies the TreeItem control type.
                _ontrolTypeDic.Add("window", 50032);  //WindowUIA_WindowControlTypeIdIdentifies the Window control type.
        }

        public static ControlType GetControlTypeFromName(string programmaticName)
        {
            UInt32 controlTypeID = _ontrolTypeDic[programmaticName.ToLower()];
            return ControlType.LookupById((int)controlTypeID);
        }
    }
}
